import os
from flask import Flask
import random

app = Flask(__name__)

music_dir = "/Users/peishuaishuai/Downloads/儿歌歌曲"

@app.route('/music')
def music():
	music_files = [file for file in os.listdir(music_dir)
				   if file.endswith(".mp3")]
	music_file = random.choice(music_files)
	os.system(f'open "{music_dir}/{music_file}"')
	return "<br/>"*10 + f"""<h1>当前播放<br/>{music_file}</h1>"""

app.run(host="0.0.0.0", port=8888)
